//
//  FocusScaleButton.swift
//  WatermarkCamera
//
//  Created by Python on 2024/7/24.
//

import UIKit
import AxcBedrock

class FocusScaleButton: UIButton {

    var scaleModel: FocusScale = .init() {
        didSet {
            if scaleModel.isShowScale {
                let scale = scaleModel.scale
                let scaleStr = String(format: "%.1f", scale).axc.removeSuffix(string: ".0")
                setTitle("\(scaleStr)x", for: .normal)
            } else {
                setTitle("•", for: .normal)
            }
            backgroundColor = scaleModel.isShowScale ? UIColor.black.withAlphaComponent(0.3) : UIColor.clear
            layer.borderColor = scaleModel.isSelected ? UIColor.white.cgColor : UIColor.clear.cgColor
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setTitleColor(UIColor.white, for: .normal)
        titleLabel?.font = 14.axc.uiFont
        layer.borderWidth = 1.0
        clipsToBounds = true
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
